

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import java.util.HashMap;
import java.util.Objects;
import java.util.Scanner;


public class ParseTest {
    static public String parse(String str)throws RuntimeException {
        char[] arr=str.toCharArray();
        int num=0;
        HashMap<Character,Integer> hm=new HashMap<>();
        for(char ch:arr){
            if(Character.isDigit(ch)){
                num++;
                hm.put(ch, hm.getOrDefault(ch,0)+1);
            }
        }
        if(num==0){
            throw new RuntimeException("DigitNotFound异常");
        //    return "";
        }

        StringBuilder sb=new StringBuilder();
        int zeroNum=hm.getOrDefault('0',0);
        for(int i=1;i<10;i++){
            for(int j=0;j<hm.getOrDefault((char)(i+'0'),0);j++){
                sb.append(i);
            }
        }
        if(sb.isEmpty()){
            return "0";
        }else{
            for(int i=0;i<zeroNum;i++){
                sb.append('0');
            }
            return new String(sb);
        }

    }
    public static void main(String[] args){
        Scanner scanner=new Scanner(System.in);
        String str="";
        File filename=new File("C:\\Users\\kkkqkx\\Desktop\\作业\\java\\作业\\文件\\text2.txt");

        while(!Objects.equals(str, "end")){
            str=scanner.next();
            try{
                String result=parse(str);
                try {
                    BufferedWriter writer=new BufferedWriter(new FileWriter(filename,true));
                    writer.newLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }catch(RuntimeException e){
                System.out.println(e);
            }
        }

    }
}
